Encoding:

P32A

001000

rt

rs

rd

SUBQ.PH

0

1000001

101

P32A

001000

rt

rs

rd

SUBQ_S.PH

1

1000001

101

6

5

5

5

1

7

3

Format:

SUBQ[_S].PH 

Subtract Fractional Halfword Vector

SUBQ.PH   rd, rs, rt

DSP

Subtract Fractional Halfword Vector

SUBQ_S.PH rd, rs, rt

DSP

Subtract Fractional Halfword Vector

Purpose:

Subtract Fractional Halfword Vector

Element-wise subtraction of one vector of Q15 fractional halfword values from another to produce a vector of Q15 fractional halfword results, with optional saturation.

Description:

rd = sat16(rs31..16

-

rt31..16) || sat16(rs15..0 - rt15..0)

The two fractional halfwords in register rt are subtracted from the corresponding fractional halfword elements in register rs.

For the non-saturating version of this instruction, each result is written to the corresponding element in register rd. In the case of overflow or underflow, the result modulo 2 is written to register rd.

For the saturating version of the instruction, the subtraction is performed using signed saturating arithmetic. If the operation results in an o verflow or an un derflow, the result is clamped to e ither the largest representable value

(0x7FFF hexadecimal) or the smallest representable value (0x8000 hexadecimal), respectively, before being written to the destination register rd.

For both instructions, if any of the individual subtractions result in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBQ.PH:
   ValidateAccessToDSPResources()
   tempB15..0 = subtract16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = subtract16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
SUBQ_S.PH:
   ValidateAccessToDSPResources()
   tempB15..0 = sat16Subtract( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = sat16Subtract( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
function subtract16( a15..0, b15..0 ) 
   temp16..0 = ( a15 || a15..0 ) - ( b15 || b15..0 )
   if ( temp16 != temp15 ) then
   return temp15..0
endfunction subtract16
function sat16Subtract( a15..0, b15..0 )
   temp16..0 = ( a15 || a15..0 ) - ( b15|| b15..0 )
   if ( temp16 != temp15 ) then
      if ( temp16 = 0 ) then
          temp = 0x7FFF
      else
          temp = 0x8000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction sat16Subtract

Exceptions:

Reserved Instruction, DSP Disabled